package com.level2app.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.QuickViewHolder;
import com.level2app.R;
/**
 * Created by S
 * time 2024/8/20
 */
public class FlowLayoutItemAdapter extends BaseQuickAdapter<String, QuickViewHolder> {

    @Override
    protected void onBindViewHolder(@NonNull QuickViewHolder holder, int i, @Nullable String s) {
        TextView textView = holder.getView(R.id.textTv);
        if (i % 2 == 0) {
            //棕色
            textView.setTextColor(ContextCompat.getColor(getContext(), R.color.color_894c4c));
            textView.setBackgroundResource(R.drawable.shape_f1e8e8_4dp);
        } else {
            //紫色
            textView.setTextColor(ContextCompat.getColor(getContext(), R.color.color_5d3d83));
            textView.setBackgroundResource(R.drawable.shape_e8e5f3_4dp);
        }
        textView.setText(s);
    }

    @NonNull
    @Override
    protected QuickViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new QuickViewHolder(R.layout.item_flow_layout, viewGroup);
    }
}